<template>
  <div class="full-screen-box">
    <i class="el-icon-full-screen" @click="toggleScreen"></i>
  </div>
</template>

<script>
import ScreenFull from 'screenfull'
export default {
  name: 'FullScreen',

  methods: {
    toggleScreen() {
      if (!ScreenFull.isEnabled) {
        // 此时全屏不可用
        this.$message.warning('此时全屏组件不可用')
        return
      }
      // document.documentElement.requestFullscreen()  原生js调用
      //   如果可用 就可以全屏
      ScreenFull.toggle()
    }
  },
}
</script>

<style lang="scss" scoped>
.el-icon-full-screen{
  color: #fff;
  font-size: 20px;
}
.full-screen-box{
  padding-top: 8px;
  width: 30px;
}
</style>
